<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>兴趣测试 - 发现你的爱好</title>
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome 图标 -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    
    <style>
        :root {
            --primary: #6366f1;
            --primary-light: #a5b4fc;
            --primary-dark: #4338ca;
            --secondary: #10b981;
            --accent: #f97316;
            --danger: #ef4444;
            --text-primary: #1f2937;
            --text-secondary: #6b7280;
            --text-light: #9ca3af;
            --bg-light: #f3f4f6;
            --bg-white: #ffffff;
            --border-light: #e5e7eb;
            --radius: 12px;
            --shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
            background-color: var(--bg-light);
            color: var(--text-primary);
            padding-top: 55px;
            padding-bottom: 70px;
        }
        
        /* 顶部导航 */
        .top-nav {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 55px;
            background-color: var(--bg-white);
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 15px;
            z-index: 1000;
            border-bottom: 1px solid var(--border-light);
            box-shadow: var(--shadow);
        }
        
        .nav-title {
            font-size: 1.15rem;
            font-weight: 600;
            color: var(--primary-dark);
        }
        
        .nav-action {
            color: var(--text-secondary);
            background: none;
            border: none;
            font-size: 1.2rem;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .nav-action:hover {
            background-color: var(--bg-light);
        }
        
        /* 搜索栏 */
        .search-container {
            padding: 12px 15px;
            background-color: var(--bg-white);
        }
        
        .search-group {
            position: relative;
        }
        
        .search-input {
            width: 100%;
            padding: 12px 15px 12px 45px;
            border-radius: 30px;
            border: 1px solid var(--border-light);
            background-color: var(--bg-light);
            font-size: 0.9rem;
        }
        
        .search-input:focus {
            outline: none;
            border-color: var(--primary-light);
            box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
        }
        
        .search-icon {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-secondary);
        }
        
        /* 筛选区域 */
        .filters-container {
            background-color: var(--bg-white);
            border-top: 1px solid var(--border-light);
        }
        
        /* 筛选器标题 */
        .filter-title {
            font-size: 0.9rem;
            color: var(--text-secondary);
            padding: 12px 15px 8px;
            font-weight: 500;
        }
        
        /* 分类筛选栏 */
        .category-filter {
            display: flex;
            padding: 8px 15px;
            background-color: var(--bg-white);
            overflow-x: auto;
            scrollbar-width: none;
        }
        
        .category-filter::-webkit-scrollbar {
            display: none;
        }
        
        .category-item {
            white-space: nowrap;
            padding: 6px 14px;
            margin-right: 8px;
            border-radius: 20px;
            font-size: 0.85rem;
            background-color: var(--bg-light);
            color: var(--text-secondary);
            border: none;
            display: flex;
            align-items: center;
        }
        
        .category-item.active {
            background-color: var(--primary);
            color: white;
        }
        
        .category-item i {
            margin-right: 5px;
        }
        
        /* 标签筛选 */
        .tags-filter {
            padding: 8px 15px;
            background-color: var(--bg-white);
            border-top: 1px solid var(--border-light);
        }
        
        .tags-container {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }
        
        .tag-item {
            padding: 5px 12px;
            background-color: var(--bg-light);
            color: var(--text-secondary);
            border-radius: 15px;
            font-size: 0.8rem;
            border: none;
        }
        
        .tag-item.active {
            background-color: rgba(99, 102, 241, 0.1);
            color: var(--primary);
            border: 1px solid var(--primary-light);
        }
        
        /* 条件筛选器 */
        .advanced-filters {
            padding: 10px 15px;
            background-color: var(--bg-white);
            border-top: 1px solid var(--border-light);
        }
        
        .filter-row {
            display: flex;
            gap: 10px;
            margin-bottom: 10px;
        }
        
        .filter-group {
            flex: 1;
        }
        
        .filter-label {
            font-size: 0.8rem;
            color: var(--text-secondary);
            margin-bottom: 5px;
            display: block;
        }
        
        .filter-select {
            width: 100%;
            padding: 8px 12px;
            border-radius: 8px;
            border: 1px solid var(--border-light);
            background-color: var(--bg-light);
            font-size: 0.85rem;
            color: var(--text-primary);
            appearance: none;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 10px center;
        }
        
        /* 筛选操作栏 */
        .filter-actions {
            display: flex;
            padding: 12px 15px;
            background-color: var(--bg-white);
            border-top: 1px solid var(--border-light);
            justify-content: space-between;
        }
        
        .reset-btn {
            padding: 8px 16px;
            background-color: var(--bg-light);
            color: var(--text-secondary);
            border: none;
            border-radius: 8px;
            font-size: 0.9rem;
        }
        
        .apply-btn {
            padding: 8px 16px;
            background-color: var(--primary);
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 0.9rem;
        }
        
        /* 筛选结果标签 */
        .active-filters {
            padding: 10px 15px;
            background-color: var(--bg-white);
            border-top: 1px solid var(--border-light);
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            align-items: center;
        }
        
        .active-filter-tag {
            background-color: rgba(99, 102, 241, 0.1);
            color: var(--primary);
            padding: 4px 10px;
            border-radius: 12px;
            font-size: 0.8rem;
            display: flex;
            align-items: center;
            gap: 5px;
        }
        
        .remove-filter {
            background: none;
            border: none;
            color: var(--primary);
            cursor: pointer;
            font-size: 0.9rem;
        }
        
        .clear-all {
            color: var(--text-secondary);
            font-size: 0.8rem;
            margin-left: auto;
            background: none;
            border: none;
        }
        
        /* 测试列表 */
        .quizzes-list {
            padding: 0 15px;
        }
        
        .quiz-card {
            background-color: var(--bg-white);
            border-radius: var(--radius);
            margin-top: 12px;
            overflow: hidden;
            box-shadow: var(--shadow);
            transition: transform 0.2s ease;
        }
        
        .quiz-card:hover {
            transform: translateY(-2px);
        }
        
        /* 无图测试卡片 */
        .quiz-card.no-image .card-body {
            padding: 18px 15px;
        }
        
        /* 单图测试卡片 */
        .quiz-card.single-image .card-image {
            height: 180px;
        }
        
        /* 多图测试卡片 */
        .card-image-container {
            position: relative;
        }
        
        .card-image {
            width: 100%;
            height: 160px;
            object-fit: cover;
        }
        
        .multi-image {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 3px;
            height: 160px;
        }
        
        .multi-image img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        
        .image-count {
            position: absolute;
            right: 8px;
            bottom: 8px;
            background-color: rgba(0, 0, 0, 0.6);
            color: white;
            font-size: 0.75rem;
            padding: 2px 8px;
            border-radius: 10px;
        }
        
        /* 测试卡片内容 */
        .card-body {
            padding: 15px;
        }
        
        .quiz-category {
            display: inline-block;
            background-color: rgba(99, 102, 241, 0.1);
            color: var(--primary);
            font-size: 0.75rem;
            padding: 3px 10px;
            border-radius: 12px;
            margin-bottom: 8px;
        }
        
        .quiz-title {
            font-size: 1.1rem;
            font-weight: 600;
            margin-bottom: 8px;
            line-height: 1.4;
        }
        
        .quiz-description {
            font-size: 0.9rem;
            line-height: 1.5;
            color: var(--text-secondary);
            margin-bottom: 12px;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
        
        /* 测试元数据 */
        .quiz-meta {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 0.8rem;
            color: var(--text-light);
            margin-bottom: 12px;
        }
        
        .meta-item {
            display: flex;
            align-items: center;
            gap: 5px;
        }
        
        /* 操作按钮 */
        .action-buttons {
            display: flex;
            gap: 10px;
        }
        
        .primary-btn {
            flex: 1;
            padding: 10px 0;
            background-color: var(--primary);
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 0.9rem;
            font-weight: 500;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 5px;
        }
        
        .primary-btn:hover {
            background-color: var(--primary-dark);
        }
        
        .secondary-btn {
            flex: 0 0 auto;
            padding: 10px;
            background-color: var(--bg-light);
            color: var(--text-secondary);
            border: none;
            border-radius: 8px;
            font-size: 0.9rem;
            font-weight: 500;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        /* 精选测试标签 */
        .featured-badge {
            position: absolute;
            top: 10px;
            left: 10px;
            background-color: var(--accent);
            color: white;
            font-size: 0.7rem;
            padding: 2px 8px;
            border-radius: 4px;
            z-index: 10;
        }
        
        /* 加载更多 */
        .load-more {
            width: 100%;
            padding: 12px;
            margin: 15px 0;
            background-color: var(--bg-white);
            border: 1px solid var(--border-light);
            border-radius: var(--radius);
            color: var(--text-secondary);
            font-size: 0.9rem;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }
        
        /* 底部导航 */
        .bottom-nav {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            height: 65px;
            background-color: var(--bg-white);
            display: flex;
            justify-content: space-around;
            align-items: center;
            border-top: 1px solid var(--border-light);
            z-index: 1000;
        }
        
        .nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            color: var(--text-secondary);
            font-size: 0.7rem;
            text-decoration: none;
        }
        
        .nav-item i {
            font-size: 1.3rem;
            margin-bottom: 3px;
        }
        
        .nav-item.active {
            color: var(--primary);
        }
        
        /* 提示消息 */
        .toast-notification {
            position: fixed;
            bottom: 80px;
            left: 50%;
            transform: translateX(-50%);
            background-color: rgba(0, 0, 0, 0.7);
            color: white;
            padding: 8px 16px;
            border-radius: 4px;
            z-index: 9999;
            font-size: 0.9rem;
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        
        .toast-notification.show {
            opacity: 1;
        }
        
        /* 空状态 */
        .empty-state {
            padding: 40px 20px;
            text-align: center;
            color: var(--text-secondary);
        }
        
        .empty-icon {
            font-size: 3rem;
            margin-bottom: 15px;
            color: var(--text-light);
        }
    </style>
</head>
<body>
    <!-- 顶部导航 -->
    <div class="top-nav">
        <button class="nav-action" id="backBtn">
            <i class="fas fa-arrow-left"></i>
        </button>
        <div class="nav-title">兴趣测试</div>
        <button class="nav-action">
            <i class="fas fa-sliders-h" id="filterToggle"></i>
        </button>
    </div>
    
    <!-- 搜索栏 -->
    <div class="search-container">
        <div class="search-group">
            <i class="fas fa-search search-icon"></i>
            <input type="text" class="search-input" placeholder="搜索兴趣测试...">
        </div>
    </div>
    
    <!-- 筛选区域 -->
    <div class="filters-container" id="filtersContainer">
        <!-- 分类筛选 -->
        <div class="filter-title">按分类筛选</div>
        <div class="category-filter">
            <button class="category-item active">
                <i class="fas fa-th"></i>全部
            </button>
            <button class="category-item">
                <i class="fas fa-music"></i>音乐
            </button>
            <button class="category-item">
                <i class="fas fa-film"></i>影视
            </button>
            <button class="category-item">
                <i class="fas fa-book"></i>文学
            </button>
            <button class="category-item">
                <i class="fas fa-utensils"></i>美食
            </button>
            <button class="category-item">
                <i class="fas fa-plane"></i>旅行
            </button>
            <button class="category-item">
                <i class="fas fa-gamepad"></i>游戏
            </button>
            <button class="category-item">
                <i class="fas fa-palette"></i>艺术
            </button>
        </div>
        
        <!-- 标签筛选 -->
        <div class="filter-title">按标签筛选</div>
        <div class="tags-filter">
            <div class="tags-container">
                <button class="tag-item active">全部标签</button>
                <button class="tag-item">性格</button>
                <button class="tag-item">情感</button>
                <button class="tag-item">职场</button>
                <button class="tag-item">趣味</button>
                <button class="tag-item">知识</button>
                <button class="tag-item">创意</button>
                <button class="tag-item">健康</button>
                <button class="tag-item">时尚</button>
                <button class="tag-item">生活</button>
            </div>
        </div>
        
        <!-- 条件筛选 -->
        <div class="filter-title">按条件筛选</div>
        <div class="advanced-filters">
            <div class="filter-row">
                <div class="filter-group">
                    <label class="filter-label">题目数量</label>
                    <select class="filter-select" id="questionCount">
                        <option value="all">全部数量</option>
                        <option value="short">少 (1-10题)</option>
                        <option value="medium">中 (11-30题)</option>
                        <option value="long">多 (31题以上)</option>
                    </select>
                </div>
                <div class="filter-group">
                    <label class="filter-label">难度</label>
                    <select class="filter-select" id="difficulty">
                        <option value="all">全部难度</option>
                        <option value="easy">简单</option>
                        <option value="medium">中等</option>
                        <option value="hard">困难</option>
                    </select>
                </div>
            </div>
            <div class="filter-row">
                <div class="filter-group">
                    <label class="filter-label">评分</label>
                    <select class="filter-select" id="rating">
                        <option value="all">全部评分</option>
                        <option value="4+">4分以上</option>
                        <option value="4.5+">4.5分以上</option>
                        <option value="5">5分</option>
                    </select>
                </div>
                <div class="filter-group">
                    <label class="filter-label">更新时间</label>
                    <select class="filter-select" id="updateTime">
                        <option value="all">全部时间</option>
                        <option value="today">今天</option>
                        <option value="week">本周</option>
                        <option value="month">本月</option>
                    </select>
                </div>
            </div>
        </div>
        
        <!-- 筛选操作 -->
        <div class="filter-actions">
            <button class="reset-btn" id="resetFilters">重置筛选</button>
            <button class="apply-btn" id="applyFilters">应用筛选</button>
        </div>
    </div>
    
    <!-- 活跃筛选标签 -->
    <div class="active-filters" id="activeFilters">
        <div class="active-filter-tag">
            音乐
            <button class="remove-filter"><i class="fas fa-times"></i></button>
        </div>
        <div class="active-filter-tag">
            性格
            <button class="remove-filter"><i class="fas fa-times"></i></button>
        </div>
        <div class="active-filter-tag">
            中 (11-30题)
            <button class="remove-filter"><i class="fas fa-times"></i></button>
        </div>
        <button class="clear-all">清除全部</button>
    </div>
    
    <!-- 测试列表 -->
    <div class="quizzes-list" id="quizzesList">
        <!-- 单图测试卡片 -->
        <div class="quiz-card single-image">
            <div class="card-image-container">
                <img src="https://picsum.photos/id/1068/800/400" alt="音乐测试封面" class="card-image">
                <span class="featured-badge">精选</span>
            </div>
            <div class="card-body">
                <span class="quiz-category">音乐</span>
                <h3 class="quiz-title">根据你的听歌习惯，测试你的音乐品味类型</h3>
                <p class="quiz-description">通过你对不同音乐风格的偏好，分析你的音乐品味类型，并推荐适合你的新歌单。</p>
                
                <div class="quiz-meta">
                    <div class="meta-item">
                        <i class="fas fa-question-circle"></i>
                        <span>15题</span>
                    </div>
                    <div class="meta-item">
                        <i class="fas fa-users"></i>
                        <span>8.7k人参与</span>
                    </div>
                    <div class="meta-item">
                        <i class="fas fa-star"></i>
                        <span>4.9分</span>
                    </div>
                </div>
                
                <div class="action-buttons">
                    <button class="primary-btn">
                        <i class="fas fa-play"></i> 开始测试
                    </button>
                    <button class="secondary-btn favorite-btn">
                        <i class="far fa-bookmark"></i>
                    </button>
                </div>
            </div>
        </div>
        
        <!-- 无图测试卡片 -->
        <div class="quiz-card no-image">
            <div class="card-body">
                <span class="quiz-category">性格测试</span>
                <h3 class="quiz-title">你的隐藏性格是什么？从20个问题看穿真实的你</h3>
                <p class="quiz-description">这个测试将通过你对日常场景的选择，分析出你隐藏的性格特质，帮助你更好地了解自己。</p>
                
                <div class="quiz-meta">
                    <div class="meta-item">
                        <i class="fas fa-question-circle"></i>
                        <span>20题</span>
                    </div>
                    <div class="meta-item">
                        <i class="fas fa-users"></i>
                        <span>12.5k人参与</span>
                    </div>
                    <div class="meta-item">
                        <i class="fas fa-star"></i>
                        <span>4.8分</span>
                    </div>
                </div>
                
                <div class="action-buttons">
                    <button class="primary-btn">
                        <i class="fas fa-play"></i> 开始测试
                    </button>
                    <button class="secondary-btn favorite-btn">
                        <i class="far fa-bookmark"></i>
                    </button>
                </div>
            </div>
        </div>
        
        <!-- 多图测试卡片 -->
        <div class="quiz-card multi-image-card">
            <div class="card-image-container">
                <div class="multi-image">
                    <img src="https://picsum.photos/id/292/300/300" alt="音乐测试图片1">
                    <img src="https://picsum.photos/id/431/300/300" alt="音乐测试图片2">
                    <img src="https://picsum.photos/id/488/300/300" alt="音乐测试图片3">
                </div>
                <div class="image-count">5图</div>
            </div>
            <div class="card-body">
                <span class="quiz-category">音乐</span>
                <h3 class="quiz-title">从乐器选择看你的性格特质与创造力</h3>
                <p class="quiz-description">通过你对不同乐器的偏好和选择方式，分析你的性格特点和创造力水平。</p>
                
                <div class="quiz-meta">
                    <div class="meta-item">
                        <i class="fas fa-question-circle"></i>
                        <span>18题</span>
                    </div>
                    <div class="meta-item">
                        <i class="fas fa-users"></i>
                        <span>5.2k人参与</span>
                    </div>
                    <div class="meta-item">
                        <i class="fas fa-star"></i>
                        <span>4.7分</span>
                    </div>
                </div>
                
                <div class="action-buttons">
                    <button class="primary-btn">
                        <i class="fas fa-play"></i> 开始测试
                    </button>
                    <button class="secondary-btn favorite-btn">
                        <i class="fas fa-bookmark"></i>
                    </button>
                </div>
            </div>
        </div>
        
        <!-- 加载更多 -->
        <button class="load-more" id="loadMore">
            <i class="fas fa-spinner fa-spin"></i>
            <span>加载更多测试</span>
        </button>
    </div>
    
    <!-- 底部导航 -->
    <div class="bottom-nav">
        <a href="#" class="nav-item">
            <i class="fas fa-home"></i>
            <span>首页</span>
        </a>
        <a href="#" class="nav-item active">
            <i class="fas fa-clipboard-check"></i>
            <span>测试</span>
        </a>
        <a href="#" class="nav-item">
            <i class="fas fa-compass"></i>
            <span>发现</span>
        </a>
        <a href="#" class="nav-item">
            <i class="far fa-user"></i>
            <span>我的</span>
        </a>
    </div>
    
    <!-- Bootstrap JS Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
    
    <script>
        // 筛选面板切换
        const filterToggle = document.getElementById('filterToggle');
        const filtersContainer = document.getElementById('filtersContainer');
        
        filterToggle.addEventListener('click', () => {
            if (filtersContainer.style.display === 'none') {
                filtersContainer.style.display = 'block';
                showToast('显示筛选面板');
            } else {
                filtersContainer.style.display = 'none';
                showToast('隐藏筛选面板');
            }
        });
        
        // 分类筛选切换
        const categoryItems = document.querySelectorAll('.category-item');
        categoryItems.forEach(item => {
            item.addEventListener('click', () => {
                categoryItems.forEach(i => i.classList.remove('active'));
                item.classList.add('active');
                updateActiveFilters();
            });
        });
        
        // 标签筛选切换
        const tagItems = document.querySelectorAll('.tag-item');
        tagItems.forEach(item => {
            item.addEventListener('click', () => {
                // 如果点击的是"全部标签"，则取消其他标签的选中状态
                if (item.textContent === '全部标签') {
                    tagItems.forEach(i => i.classList.remove('active'));
                    item.classList.add('active');
                } else {
                    // 取消"全部标签"的选中状态
                    tagItems[0].classList.remove('active');
                    item.classList.toggle('active');
                }
                updateActiveFilters();
            });
        });
        
        // 应用筛选
        document.getElementById('applyFilters').addEventListener('click', () => {
            applyFilters();
            filtersContainer.style.display = 'none';
        });
        
        // 重置筛选
        document.getElementById('resetFilters').addEventListener('click', () => {
            // 重置分类
            categoryItems.forEach(i => i.classList.remove('active'));
            categoryItems[0].classList.add('active');
            
            // 重置标签
            tagItems.forEach(i => i.classList.remove('active'));
            tagItems[0].classList.add('active');
            
            // 重置下拉选择
            document.getElementById('questionCount').value = 'all';
            document.getElementById('difficulty').value = 'all';
            document.getElementById('rating').value = 'all';
            document.getElementById('updateTime').value = 'all';
            
            // 更新活跃筛选标签
            updateActiveFilters(true);
            
            showToast('已重置所有筛选条件');
        });
        
        // 清除单个筛选条件
        document.querySelectorAll('.remove-filter').forEach(btn => {
            btn.addEventListener('click', (e) => {
                e.stopPropagation();
                const tag = btn.closest('.active-filter-tag');
                const filterText = tag.textContent.trim();
                tag.remove();
                
                // 这里可以根据实际筛选条件移除对应的筛选状态
                showToast(`已移除筛选: ${filterText}`);
                
                // 如果没有筛选条件了，隐藏活跃筛选栏
                if (document.querySelectorAll('.active-filter-tag').length === 0) {
                    document.getElementById('activeFilters').style.display = 'none';
                }
                
                // 重新应用筛选
                applyFilters();
            });
        });
        
        // 清除全部筛选条件
        document.querySelector('.clear-all').addEventListener('click', () => {
            document.getElementById('resetFilters').click();
            document.getElementById('activeFilters').innerHTML = `
                <button class="clear-all">清除全部</button>
            `;
        });
        
        // 更新活跃筛选标签
        function updateActiveFilters(reset = false) {
            if (reset) {
                document.getElementById('activeFilters').innerHTML = `
                    <button class="clear-all">清除全部</button>
                `;
                return;
            }
            
            // 获取选中的分类
            const activeCategory = document.querySelector('.category-item.active:not(:first-child)');
            
            // 获取选中的标签
            const activeTags = Array.from(document.querySelectorAll('.tag-item.active:not(:first-child)')).map(tag => tag.textContent);
            
            // 获取选中的条件
            const questionCount = document.getElementById('questionCount');
            const selectedQuestionCount = questionCount.options[questionCount.selectedIndex].text;
            
            // 构建活跃筛选标签
            let activeFiltersHTML = '';
            
            if (activeCategory) {
                activeFiltersHTML += `
                    <div class="active-filter-tag">
                        ${activeCategory.textContent.trim()}
                        <button class="remove-filter"><i class="fas fa-times"></i></button>
                    </div>
                `;
            }
            
            activeTags.forEach(tag => {
                activeFiltersHTML += `
                    <div class="active-filter-tag">
                        ${tag}
                        <button class="remove-filter"><i class="fas fa-times"></i></button>
                    </div>
                `;
            });
            
            if (questionCount.value !== 'all') {
                activeFiltersHTML += `
                    <div class="active-filter-tag">
                        ${selectedQuestionCount}
                        <button class="remove-filter"><i class="fas fa-times"></i></button>
                    </div>
                `;
            }
            
            activeFiltersHTML += `<button class="clear-all">清除全部</button>`;
            
            document.getElementById('activeFilters').innerHTML = activeFiltersHTML;
            
            // 重新绑定清除单个筛选条件的事件
            document.querySelectorAll('.remove-filter').forEach(btn => {
                btn.addEventListener('click', (e) => {
                    e.stopPropagation();
                    const tag = btn.closest('.active-filter-tag');
                    const filterText = tag.textContent.trim();
                    tag.remove();
                    showToast(`已移除筛选: ${filterText}`);
                    applyFilters();
                });
            });
            
            // 重新绑定清除全部筛选条件的事件
            document.querySelector('.clear-all').addEventListener('click', () => {
                document.getElementById('resetFilters').click();
                document.getElementById('activeFilters').innerHTML = `
                    <button class="clear-all">清除全部</button>
                `;
            });
            
            // 显示活跃筛选栏
            document.getElementById('activeFilters').style.display = 'flex';
        }
        
        // 应用筛选条件
        function applyFilters() {
            // 获取所有筛选条件
            const activeCategory = document.querySelector('.category-item.active').textContent.trim();
            const activeTags = Array.from(document.querySelectorAll('.tag-item.active:not(:first-child)')).map(tag => tag.textContent);
            const questionCount = document.getElementById('questionCount').value;
            const difficulty = document.getElementById('difficulty').value;
            const rating = document.getElementById('rating').value;
            const updateTime = document.getElementById('updateTime').value;
            
            // 显示加载状态
            const quizzesList = document.getElementById('quizzesList');
            quizzesList.innerHTML = `
                <div class="d-flex justify-content-center p-5">
                    <div class="spinner-border text-primary" role="status">
                        <span class="visually-hidden">Loading...</span>
                    </div>
                </div>
            `;
            
            // 模拟筛选延迟
            setTimeout(() => {
                // 在实际应用中，这里会根据筛选条件从服务器请求数据
                // 这里简单恢复原始列表
                quizzesList.innerHTML = document.getElementById('quizzesList').dataset.originalContent;
                
                // 构建筛选描述文本
                let filterDesc = [];
                if (activeCategory !== '全部') filterDesc.push(activeCategory);
                if (activeTags.length > 0) filterDesc.push(`${activeTags.length}个标签`);
                if (questionCount !== 'all') filterDesc.push(`题目数量: ${document.getElementById('questionCount').options[document.getElementById('questionCount').selectedIndex].text}`);
                
                const filterText = filterDesc.length > 0 ? 
                    `已应用筛选: ${filterDesc.join(', ')}` : 
                    '已显示全部测试';
                
                showToast(filterText);
                
                // 重新绑定事件
                bindEvents();
            }, 1000);
        }
        
        // 收藏功能
        function bindEvents() {
            const favoriteButtons = document.querySelectorAll('.favorite-btn:not([data-bound])');
            favoriteButtons.forEach(btn => {
                btn.setAttribute('data-bound', 'true');
                btn.addEventListener('click', () => {
                    const icon = btn.querySelector('i');
                    
                    if (icon.classList.contains('far')) {
                        icon.classList.remove('far');
                        icon.classList.add('fas');
                        icon.style.color = '#6366f1';
                        showToast('收藏成功');
                    } else {
                        icon.classList.remove('fas');
                        icon.classList.add('far');
                        icon.style.color = '';
                        showToast('取消收藏');
                    }
                });
            });
            
            // 开始测试按钮
            const startButtons = document.querySelectorAll('.primary-btn:not([data-bound])');
            startButtons.forEach(btn => {
                btn.setAttribute('data-bound', 'true');
                btn.addEventListener('click', () => {
                    const quizTitle = btn.closest('.quiz-card').querySelector('.quiz-title').textContent;
                    showToast(`正在进入测试：${quizTitle}`);
                });
            });
            
            // 加载更多
            document.getElementById('loadMore').addEventListener('click', function() {
                const btn = this;
                const originalText = btn.innerHTML;
                btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i><span>加载中...</span>';
                btn.disabled = true;
                
                // 模拟加载延迟
                setTimeout(() => {
                    btn.innerHTML = originalText;
                    btn.disabled = false;
                    showToast('已加载更多测试');
                    
                    // 复制第一个测试卡片并修改内容
                    const quizzesList = document.getElementById('quizzesList');
                    const firstCard = quizzesList.querySelector('.quiz-card:first-of-type');
                    
                    if (firstCard) {
                        const clone = firstCard.cloneNode(true);
                        // 修改一些内容以示区别
                        const randomId = Math.floor(Math.random() * 100) + 200;
                        if (clone.querySelector('.card-image')) {
                            clone.querySelector('.card-image').src = `https://picsum.photos/id/${randomId}/800/400`;
                        }
                        
                        // 重置收藏状态
                        const favoriteBtn = clone.querySelector('.favorite-btn');
                        if (favoriteBtn.querySelector('.fas.fa-bookmark')) {
                            favoriteBtn.innerHTML = '<i class="far fa-bookmark"></i>';
                        }
                        
                        // 插入到加载更多按钮前
                        quizzesList.insertBefore(clone, btn);
                        
                        // 重新绑定事件
                        bindEvents();
                    }
                }, 1500);
            });
        }
        
        // 返回按钮
        document.getElementById('backBtn').addEventListener('click', () => {
            showToast('返回上一页');
        });
        
        // 提示消息
        function showToast(message) {
            // 检查是否已有toast
            let toast = document.querySelector('.toast-notification');
            if (toast) {
                toast.remove();
            }
            
            // 创建新toast
            toast = document.createElement('div');
            toast.className = 'toast-notification';
            toast.textContent = message;
            
            document.body.appendChild(toast);
            
            // 显示toast
            setTimeout(() => {
                toast.classList.add('show');
            }, 10);
            
            // 3秒后隐藏并移除
            setTimeout(() => {
                toast.classList.remove('show');
                setTimeout(() => toast.remove(), 300);
            }, 3000);
        }
        
        // 页面加载完成后保存原始列表内容
        window.addEventListener('DOMContentLoaded', () => {
            document.getElementById('quizzesList').dataset.originalContent = document.getElementById('quizzesList').innerHTML;
            bindEvents();
        });
    </script>
</body>
</html>

